<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>

<body>

    <button data-action="save">保存</button>
    <button data-action="del">删除</button>
    <button data-action="edit">编辑</button>
    <script>
        document.onclick = function (e) {
            const action = e.target.dataset.action;
            if (action === 'save') {
                console.log(1);
            }
            if (action === 'del') {
                console.log(2);
            }
            if (action === 'edit') {
                console.log(3);
            }
        }



    </script>

</body>

</html>